package com.gitee.kenewstar.utils;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

/**
 * 集合工具类
 *
 * @author kenewstar
 * @date 2022/2/25
 */
public abstract class CollectUtil {

	public static <T> Set<T> newHashSet(T[] t) {
		return new HashSet<>(Arrays.asList(t));
	}

	public static <T> Set<T> newLinkedHashSet(T[] t) {
		return new LinkedHashSet<>(Arrays.asList(t));
	}

	public static <T> boolean isEmpty(T[] t) {
		return Objects.isNull(t) || t.length == 0;
	}

	public static <T> boolean isNotEmpty(T[] t) {
		return !isEmpty(t);
	}

	public static boolean isEmpty(Collection<?> collection) {
		return collection.isEmpty();
	}

	public static boolean isNotEmpty(Collection<?> collection) {
		return !isEmpty(collection);
	}


}
